package com.gzone.contentprovider.utils;

import java.util.Date;

public class KombonentUtils {
	public static Date getTime(String src) {

		int start = src.indexOf('(');
		int end = src.indexOf('+');
		if (end < 0) {
			end = src.indexOf('-');
		}
		long t = System.currentTimeMillis();
		try {
			t = Long.parseLong(src.substring(start + 1, end));
		} catch (Exception e) {

		}
		String sub = src.substring(end, src.length() - 1);
		Date d = new Date(t);
		String ssr = DateTimeUtil.dateToString(d, "yyyy-MM-dd HH:mm:ss.SSS" + sub);
		d = DateTimeUtil.stringToDate(ssr, "yyyy-MM-dd HH:mm:ss.SSSZ");
		ssr = DateTimeUtil.dateToString(d, "dd-MM-yyyy HH:mm");
		System.out.println(ssr);
		return d;
	}

	public static String getTimeAsString(String src) {

		int start = src.indexOf('(');
		int end = src.indexOf('+');
		if (end < 0) {
			end = src.indexOf('-');
		}
		long t = System.currentTimeMillis();
		try {
			t = Long.parseLong(src.substring(start + 1, end));
		} catch (Exception e) {

		}
		String sub = src.substring(end, src.length() - 1);
		Date d = new Date(t);
		String ssr = DateTimeUtil.dateToString(d, "yyyy-MM-dd HH:mm:ss.SSS" + sub);
		d = DateTimeUtil.stringToDate(ssr, "yyyy-MM-dd HH:mm:ss.SSSZ");
		ssr = DateTimeUtil.dateToString(d, "dd-MM-yyyy HH:mm");
		return ssr;
	}
}
